const modules = import.meta.glob('../views/**/*.vue')
const addRouter = (router) => {
  const menuList = JSON.parse(window.sessionStorage.getItem('menuList') || '[]')
  const routerConfig = [
  ]
  for (const path in modules) {
    if (!path.includes('views/layout')) {
      let name = path.split('/').pop().replace('.vue', '')
      routerConfig.push({
        name: name,
        path: '/' + name,
        component: () => import(`../views/${name}.vue`)
      })
    }
  }
  // const routerConfig = menuList.map((item) => {
  //   return {
  //     name: item.name,
  //     path: '/' + item.path,
  //     component: () => import(`../views/${item.path}.vue`)
  //   }
  // })
  const route = 
     {
      path: '/main',
      meta: { title: '首页' },
    component: () => import('@/views/main.vue'),
    children: [{
      path: '/main/home',
      meta: { title: '首页' },
      component: () => import('@/views/home.vue'),
    }]
     }
  
return route
}
export default addRouter